import Taro from "@tarojs/taro";
const account = Taro.getAccountInfoSync();
console.log("account:", account);
let env: string = account.miniProgram.envVersion;
console.log("env:", env);
let localEnv: string = Taro.getStorageSync("localEnv") || "";
// env = 'release'
// console.log('env:',env,localEnv)
if (env !== localEnv) {
  Taro.clearStorageSync();
  Taro.setStorageSync("localEnv", env);
}

const globalConfig: object = {
  develop: {
    url: "https://d-app-api.wanhuhealth.com/sec",
    wanhu: "https://ddemo.wanhuhealth.com",
  },
  trial: {
    url: "https://d-app-api.wanhuhealth.com/sec",
    wanhu: "https://ddemo.wanhuhealth.com",
  },
  release: {
    url: "https://app-api.wanhuhealth.com/sec",
    wanhu: "https://weixin-api.wanhuhealth.com",
  },
};
const globalData = {
  appid: "wx46f78002c76bba30",
  url: globalConfig[env].url || "https://d-app-api.wanhuhealth.com/sec",
  whUrl: globalConfig[env].wanhu || "https://ddemo.wanhuhealth.com",
  defaultShareData: {
    title: "",
    path: "/pages/index/index",
    imageUrl:
      "https://wanhuhealth.oss-cn-beijing.aliyuncs.com/static/note-miniProgram/share.png?v=2",
  },
  isDev: env !== "release",
  isRelease : env === "release",
  navBarHeight: "160rpx",
  jifenBaoProductId:22,
};

export function setGlobalData(key: string, value: any) {
  globalData[key] = value;
}

export function getGlobalData(key: string) {
  return globalData[key];
}
